package cn.lanqiao.bigDate.mapper.data;


import cn.lanqiao.bigDate.entity.data.DataStock;
import cn.lanqiao.bigDate.entity.data.result.ResultBookSeller;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DataStockMapper extends BaseMapper<ResultBookSeller> {

    @Select("SELECT m1.*,left(m1.date, 7) as month\n" +
            "FROM data_stock m1\n" +
            "WHERE 10>(\n" +
            "    SELECT COUNT(1)\n" +
            "    FROM data_stock m2\n" +
            "    WHERE m1.`stock`<m2.`stock` AND left(m1.date, 7) =left(m1.date, 7) \n" +
            "    )\n" +
            "ORDER BY left(m1.date, 7) ,m1.stock desc;")
    List<DataStock> selectStockGroupByMonth();
}
